<!--
 * @Description: 
 * @Version: 2.0
 * @Autor: 刘世琪
 * @Date: 2021-02-01 21:26:07
 * @LastEditors: Seven
 * @LastEditTime: 2021-02-06 00:37:09
-->
<template>
    <div>
      <h1>订单详情</h1>
        <table border="1">
            <tr>
                <td>订单号</td>
                <td>教练</td>
                <td>用户</td>
                <td>价格</td>
                <td>下单时间</td>
                <td>结束时间</td>
            </tr>
             <tr v-for="order in order_list" :key="order.id">
                <td>{{order.ordernum}}</td> 
                <td>{{order.coach.name}}</td>
                <td>{{order.user.username}}</td>
                <td>{{order.cost_money}}元</td>
                <td>{{getLocalTime(order.start_time)}}</td>
                <td>{{getLocalTime(order.end_time)}}</td>
            </tr>
        </table> 
        
    </div>
</template>

<script>
import axios from 'axios'

export default {
    data() {
        return {
            order_list:{},
            base_url:'http://127.0.0.1:8000/',
            num_id:this.$route.query.id,
        }
    },
    mounted:function(){
        this.get_order()
    },
    methods: {
        getLocalTime(nS) {     
            return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
        },
        get_order(){
            axios({
                url:this.base_url + 'order_list/'
            }).then(res=>{
                console.log(res.data)
                this.order_list = res.data
            })
        }

    },
    created() {

    }
}
</script>

<style>
table{
    width: 750px;
    height: 50px; 
    border: solid burlywood;
    margin: 0 auto;
    border-collapse:collapse
}
td{
    border: green solid;
    border-collapse:collapse
}


</style>
